import React, { Component } from 'react';

export default class ComponentOld extends Component{
  constructor(props) {
    super(props);
    this.state={
      text:'demo'
    }
    // 第二种绑定
    // this.handleClick=this.handleClick.bind(this)
    console.log('constructor')
  }
  componentWillMount() {
    console.log('componentWillMount')
  }
  componentDidMount() {
    console.log('componentDidMount')
  }
  componentWillUpdate(){
    console.log('componentWillUpdate')
  }
  componentDidUpdate(){
    console.log('componentDidUpdate')
  }

  shouldComponentUpdate(nextProps, nextState, nextContext) {
    console.log('shouldComponentUpdate')
    console.log(nextProps,nextState)
    return true
  }

  componentWillUnmount() {
    console.log('componentWillUnMount')
  }

  render() {
    console.log('render')
    return (
      <div onClick={this.handleClick}>
        component-old - {this.state.text}
      </div>
    );
  }
  handleClick=()=>{
    this.setState({
      text:'demo2'
    })
  }

}
